package com.hl.sfzy.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hl.sfzy.entity.Company;
import com.hl.sfzy.entity.course.Course;
import com.hl.sfzy.entity.my.MyAnswer;
import com.hl.sfzy.mapper.CompanyMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class CompanyService {
    @Autowired
    private CompanyMapper companyMapper;

    //查询我的公司
    public Company company(int id){
        return companyMapper.selectByPrimaryKey(id);
    }

//    查询全部公司
    public PageInfo<Company> companyAllContent(Integer page, Integer size) {
        PageHelper.startPage(page, size);
        List list = companyMapper.companyAllContent();
        PageInfo<Company> pageInfo = new PageInfo<>(list);

        return pageInfo;
    }

    //模糊搜索
    public PageInfo<Company> companyLikeSearch(Integer page, Integer size,String name){
        PageHelper.startPage(page, size);
        List list = companyMapper.companyLikeSearch(name);
        PageInfo<Company> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    //新增公司
    public int companyInsert(Company company) {
        return companyMapper.insertSelective(company);
    }
    //删除公司
    public int companyDelete(Long id) {
        return companyMapper.deleteByPrimaryKey(id);
    }

    //修改公司
    public int updateCompany(Company company){
        return   companyMapper.updateByPrimaryKeySelective(company);
    }
}
